//
//  ContentViewController.m
//  忘不了
//
//  Created by rimi on 16/7/16.
//  Copyright © 2016年 handuan. All rights reserved.
//

#import "ContentViewController.h"
#import "SDAutoLayout.h"

@interface ContentViewController ()
@property (nonatomic,strong) UITextView *contentTextView;
@property (nonatomic,strong) UIImageView *bgImageView;
@property (nonatomic,strong) UIImageView *textImageView;
@end

@implementation ContentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self loadUI];
    
}

- (void)loadUI{
    
    _bgImageView = [[UIImageView alloc]init];
    [_bgImageView setImage:[UIImage imageNamed:@"s"]];
    [self.view addSubview:_bgImageView];
    _bgImageView.sd_layout.topSpaceToView(self.view,0).leftSpaceToView(self.view,0).rightSpaceToView(self.view,0).bottomSpaceToView(self.view,0);
    
    _textImageView = [[UIImageView alloc]init];
    [_textImageView setImage:[UIImage imageNamed:@"便签"]];
    [self.view addSubview: _textImageView];
    _textImageView.sd_layout.topSpaceToView(self.view,60).leftSpaceToView(self.view,10).rightSpaceToView(self.view,10).bottomSpaceToView(self.view,250);
    
    UIBarButtonItem *doneItem = [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(doneItemPressed)];
    self.navigationItem.rightBarButtonItem = doneItem;
    
    _contentTextView = [[UITextView alloc]init];
    _contentTextView.backgroundColor = [UIColor clearColor];
    _contentTextView.font = [UIFont systemFontOfSize:18];
    _contentTextView.text = _contentString;
    [_contentTextView becomeFirstResponder];
    [self.view addSubview:_contentTextView];
    _contentTextView.sd_layout.leftSpaceToView(self.view,20).rightSpaceToView(self.view,20).topSpaceToView(self.view,150).heightIs(200);
}

- (void)doneItemPressed{
    //调用协议方法
    if (_delegate && [_delegate respondsToSelector:@selector(addContent:)]) {
        [_delegate addContent:_contentTextView.text];
    }
    [self.navigationController popViewControllerAnimated:YES];
}


@end
